import jieba
import fasttext

jieba.add_word("八宝鸭")
jieba.add_word("牛毽子肉")
jieba.add_word("帝王蟹")
jieba.add_word("红膏炝蟹")
jieba.add_word("红膏蟹")
jieba.add_word("下水管道")
jieba.add_word("卤牛肉")

# 分词示例
text = "如何在家自制八宝鸭"
text_seg = " ".join(jieba.cut(text))
print(text_seg, type(text_seg))


# 假设模型已经训练好并保存为model_filename.ftz
model = fasttext.load_model("models/td_dim32_b3.ftz")

# 使用分词后的文本进行预测
prediction = model.predict(text_seg)
print(text)
print(prediction)


# print(model.get_word_id(text))

print(model.get_labels())
